1. Field of the invention
The present invention relates generally to computer methods for vector processing and specifically to methods for writing a scalar value to a vector stored in a computer system.
2. Description of Related Art
Several applications such as 3-D graphics, medical imaging and scientific modelling require modern computers to be able to operate on vectors.
In some computer systems, the process of substituting a single element of a vector is carried out by first reading a vector from storage, modifying the vector and then writing the entire vector back to the storage. FIG. 1 shows a typical prior art microprocessor 100 having an ALU 110 whose output is connected to a register bank 130 via an on-chip bus 120. The register bank 130 is, in turn, connected to the inputs of ALU 110 via buses 140 and 150.
To replace an element of a vector 160 stored in register 170, the contents of register 170 are first read onto bus 140 to be fed to input 180 of ALU 110. Similarly, scalar element 165 stored in register 175 is read onto bus 150 to be fed to input 190 of ALU 110. A second scalar value 167, stored in register 172 and representing the position at which scalar element 165 is to be inserted into vector 160, must also be read from register bank 130 onto ALU 110. ALU 110 then copies scalar element 165 into a specified position of vector 160 and the modified vector is written out to on-chip bus 120 to be written back to register 170.
As vector processing becomes more and more common in modern computers for such applications as 3D-graphics, medical imaging and scientific modelling, it becomes increasingly desirable to replace vector elements fast.
In FIG. 1, three operands are read from the register bank 130 to the ALU 110. Register bank 130 has only two output ports and, therefore, two clock cycles are required to read all three operands from the register bank 130, in addition to a third cycle to replace the element in the vector in the ALU 110 and a fourth cycle to write the vector back into the register 170.